Codeforces Round 643 , Problem D. Game With Array